/*
 * LocalNode.hpp
 *
 *  Created on: Nov 21, 2014
 *      Author: toti
 */

#ifndef LOCALNODE_HPP_
#define LOCALNODE_HPP_

#include <string>
#include <list>
#include <fstream>

#include <Misc/Config.hpp>
#include <Connectivity/TCPConnection.hpp>
#include <Network/MessagePackages/MessagePackage.hpp>
#include <Network/MessagePackages/ClientMessagePackage.hpp>
#include <Network/MessagePackages/ServerMessagePackage.hpp>


class LocalNode{

public:

	enum LocalNodeType{
		LOCAL_NODE_CLIENT,
		LOCAL_NODE_SERVER
	};

protected:

	LocalNodeType localNodeType;

	std::ofstream *rawDataLogOutputStream;

	TCPConnection *tcpConnection;

	std::string inputStr;

public:

	LocalNode(TCPConnection *tcpConnection, LocalNodeType localNodeType);
	virtual ~LocalNode(){}

	virtual MessagePackage *buildPackage(std::string& input) = 0;

	bool handleInputData(std::list<MessagePackage*> *messageList);
	void handleOutputData(MessagePackage *messagePackage);

	TCPConnection *getTcpConnection();

	LocalNodeType getLocalNodeType();
};


#endif /* LOCALNODE_HPP_ */
